package com.todo.content.application.frontend.controller;

import com.todo.common.common.entity.response.BizResponse;
import com.todo.content.application.frontend.service.ContentTopicAggService;
import com.todo.content.iface.frontend.ContentTopicFrontendIface;
import com.todo.content.iface.frontend.request.ContentTopicBaseListParam;
import com.todo.content.iface.frontend.request.QueryContentTopicDetailByIdParam;
import com.todo.content.iface.frontend.request.RecommendContentTopicListParam;
import com.todo.content.iface.frontend.response.ContentTopicBaseVO;
import com.todo.content.iface.frontend.response.ContentTopicDetailVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author azhebuxing
 * @date 2024/5/17 13:47
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/content")
@Tag(name = "内容话题前台接口", description = "内容话题前台接口")
public class ContentTopicFrontendController implements ContentTopicFrontendIface {

    @Resource
    private ContentTopicAggService contentTopicAggService;


    @Override
    @Operation(summary = "根据话题查询内容列表")
    @PostMapping("/queryContentTopicBaseList")
    public BizResponse<List<ContentTopicBaseVO>> queryContentTopicBaseList(@RequestBody ContentTopicBaseListParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return contentTopicAggService.queryContentTopicBaseList(param);
    }

    @Override
    @Operation(summary = "推荐话题列表")
    @PostMapping("/baseRecommendContentTopicList")
    public BizResponse<List<ContentTopicBaseVO>> baseRecommendContentTopicList(@RequestBody RecommendContentTopicListParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return contentTopicAggService.baseRecommendContentTopicList(param);
    }

    @Override
    @Operation(summary = "根据话题查询话题详情")
    @PostMapping("/queryContentTopicDetailById")
    public BizResponse<ContentTopicDetailVO> queryContentTopicDetailById(@RequestBody QueryContentTopicDetailByIdParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return contentTopicAggService.queryContentTopicDetailById(param);
    }
}
